import { Divider, Skeleton } from "antd"
import InfiniteScroll from "react-infinite-scroll-component"
import styles from './index.less'
type Props ={
    dataSource:any[],
    next:any,
    hasMore:boolean,
    renderItem:any,
    loading:boolean,
}

export default ({dataSource,next,hasMore,renderItem,loading}:Props) =>{
    return <div   className={styles.container} >
         <InfiniteScroll
              dataLength={dataSource?.length}
              next={next}
              hasMore={hasMore}
              loader={null}
              endMessage={ loading ? null: <>{dataSource?.length >0 ?<Divider plain>没有更多了</Divider>:<Divider plain>暂无数据</Divider>}</>}
              initialScrollY={0}
           >
            {
                loading ?
                 <Skeleton  paragraph={{ rows: 2 }} active /> :dataSource?.map?.((item,index)=>{
                    return <div key={index}>{renderItem(item,index)}</div>
                })
            }
         </InfiniteScroll>
    </div>
}